package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.DesignatedPersonnel;
import com.ruoyi.system.service.IDesignatedPersonnelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 指定人员处理业务Controller
 * 
 * @author ruoyi
 * @date 2022-09-24
 */
@RestController
@RequestMapping("/system/personnel")
public class DesignatedPersonnelController extends BaseController
{
    @Autowired
    private IDesignatedPersonnelService designatedPersonnelService;

    /**
     * 查询指定人员处理业务列表
     */
    @PreAuthorize("@ss.hasPermi('system:personnel:list')")
    @GetMapping("/list")
    public TableDataInfo list(DesignatedPersonnel designatedPersonnel)
    {
        startPage();
        List<DesignatedPersonnel> list = designatedPersonnelService.selectDesignatedPersonnelList(designatedPersonnel);
        return getDataTable(list);
    }

    /**
     * 获取指定人员处理业务详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:personnel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(designatedPersonnelService.selectDesignatedPersonnelById(id));
    }

    /**
     * 新增指定人员处理业务
     */
    @PreAuthorize("@ss.hasPermi('system:personnel:add')")
    @Log(title = "指定人员处理业务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DesignatedPersonnel designatedPersonnel)
    {
        return toAjax(designatedPersonnelService.insertDesignatedPersonnel(designatedPersonnel));
    }

    /**
     * 修改指定人员处理业务
     */
    @PreAuthorize("@ss.hasPermi('system:personnel:edit')")
    @Log(title = "指定人员处理业务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DesignatedPersonnel designatedPersonnel)
    {
        return toAjax(designatedPersonnelService.updateDesignatedPersonnel(designatedPersonnel));
    }

    /**
     * 删除指定人员处理业务
     */
    @PreAuthorize("@ss.hasPermi('system:personnel:remove')")
    @Log(title = "指定人员处理业务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(designatedPersonnelService.deleteDesignatedPersonnelByIds(ids));
    }
}
